﻿using DotNetCoreApi.Plugins.SignalR;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Plugins.SignalR;
using System.Threading.Tasks;

namespace DotNetCoreApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SignalRController : BaseController
    {
        public SignRHelper SignRHelper { get; set; }
        /// <summary>
        /// 给所有人发送信息
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task SendAll(string msg, string id)
        {
            await SignRHelper.SendAll(msg,id);
        }
        /// <summary>
        /// 给某人发送消息
        /// </summary>
        /// <param name="msg">消息</param>
        /// <param name="id">发送者id</param>
        /// <param name="toId">接收者id</param>
        /// <returns></returns>
        [HttpGet]
        public async Task SendTo(string msg, string id, string toId)
        {
            await SignRHelper.SendTo(msg, id,toId);

        }
    }
}
